package _interview150;

import _object.ListNode;

/**
 * 82. 删除排序链表中的重复元素 II
 */
public class No82 {
    public ListNode deleteDuplicates(ListNode head) {
        ListNode dummy = new ListNode(-1, head), p0 = dummy;
        while (p0.next != null) {
            ListNode nex = p0.next;
            if (nex.next != null && nex.val == nex.next.val) {
                while (nex.next != null && nex.val == nex.next.val) {
                    nex = nex.next;
                }
                p0.next = nex.next;
            } else p0 = p0.next;
        }
        return dummy.next;
    }
}
